import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('@/views/Home.vue')
  },
  {
    path: '/form',
    component: () => import('@/views/Form.vue')
  },
  {
    path: '/thank',
    component: () => import('@/views/Thank.vue')
  }
]

const router = new VueRouter({
  routes,
  // 解决 vue 中跳转页面后滚动条没有在最顶端问题
  scrollBehavior (to, from, saveTop) {
    if (saveTop) {
      return saveTop
    } else {
      return {
        x: 0,
        y: 0,
        // 配置动画平滑滚动
        behavior: 'smooth'
      }
    }
  }
})

export default router
